﻿<Page
    x:Name="pageRoot"
    x:Class="Atletika.HubPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Atletika"
    xmlns:data="using:Atletika.Data"
    xmlns:common="using:Atletika.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    
    <Page.Resources>
        <local:ArticleTemplateSelector x:Name="MyArticleTemplateSelector" 
                                       TopArticleTemplate="{StaticResource NewTopArticleTemplate}" 
                                       StandardArticleTemplate="{StaticResource NewArticleTemplate}"/>
    </Page.Resources>

    <Page.BottomAppBar>
        <CommandBar>
            <AppBarButton Label="Obnoviť" Icon="Refresh" Click="Refresh_Click"/>
            <AppBarButton Label="Web" Icon="Globe" Click="Info_Click"/>
        </CommandBar>
    </Page.BottomAppBar>

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>

        <Hub SectionHeaderClick="Hub_SectionHeaderClick" Padding="20,30,20,10">

            <!-- HEADER -->
            <Hub.Header>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="60"/>
                        <ColumnDefinition Width="auto"/>
                    </Grid.ColumnDefinitions>
                    <ProgressRing x:Name="progressRing" Width="40" Height="40" Foreground="White" HorizontalAlignment="Left" />
                    <TextBlock x:Name="pageTitle" Text="{StaticResource AppName}" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1" 
                        VerticalAlignment="Top" IsHitTestVisible="false" TextWrapping="NoWrap" />
                </Grid>
            </Hub.Header>

            <!-- AKTUALITY -->
            <HubSection Header="Aktuality" IsHeaderInteractive="True" DataContext="{Binding HomeArticles}" 
                        Padding="50,20,20,10" Tag="{StaticResource ARTICLES_TAG}">
                <DataTemplate>
                    <GridView ItemsSource="{Binding}" ItemTemplateSelector="{StaticResource MyArticleTemplateSelector}" SelectionMode="None"
                              IsItemClickEnabled="True" ItemClick="ArticleSelected" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                        <GridView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <VariableSizedWrapGrid ItemWidth="260" ItemHeight="200" MaximumRowsOrColumns="3" Orientation="Horizontal" />
                            </ItemsPanelTemplate>
                        </GridView.ItemsPanel>
                    </GridView>
                </DataTemplate>
            </HubSection>

            <!-- ZO SVETA -->
            <HubSection Header="Zo sveta" IsHeaderInteractive="True" DataContext="{Binding WorldArticles}" 
                        Padding="20,20,20,10" Tag="{StaticResource ARTICLES_TAG}">
                <DataTemplate>
                    <GridView ItemsSource="{Binding}" ItemTemplateSelector="{StaticResource MyArticleTemplateSelector}" SelectionMode="None"
                              IsItemClickEnabled="True" ItemClick="ArticleSelected" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                        <GridView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <VariableSizedWrapGrid ItemWidth="260" ItemHeight="200" MaximumRowsOrColumns="3" Orientation="Horizontal" />
                            </ItemsPanelTemplate>
                        </GridView.ItemsPanel>
                    </GridView>
                </DataTemplate>
            </HubSection>

            <!-- PRETEKY -->
            <HubSection Header="Kalendár pretekov" IsHeaderInteractive="True" DataContext="{Binding Competitions}" 
                        Padding="20,20,50,10" MaxWidth="700" Tag="{StaticResource COMPETITIONS_TAG}">
                <DataTemplate>
                    <GridView ItemsSource="{Binding}" ItemTemplate="{StaticResource CompetitionTemplate}" SelectionMode="None"
                              IsItemClickEnabled="True" ItemClick="CompetitionSelected" ScrollViewer.HorizontalScrollBarVisibility="Disabled" />
                </DataTemplate>
            </HubSection>

        </Hub>
    </Grid>
</Page>
